﻿using System.Collections;
using System.Collections.Generic;

namespace _21_C_中的Queue和Stack
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.Title = "C#中的Queue和Stack";

            //队列是个有序集合 先进先出  消息队列
            //Queue queue = new Queue();
            //queue.Enqueue("欢");
            //queue.Enqueue("迎");
            //queue.Enqueue("您");
            //queue.Enqueue(1);

            ////queue.Dequeue();取出移除
            ////queue.Peek();取出不移除

            //Console.WriteLine(queue.Peek());

            //foreach (var item in queue)
            //{
            //    Console.WriteLine(item);
            //}

            //Queue<string> queue = new Queue<string>();

            //queue.Enqueue("欢");
            //queue.Enqueue("迎");
            //queue.Enqueue("您");

            ////queue.Dequeue();取出移除
            ////queue.Peek();取出不移除

            //Console.WriteLine(queue.Peek());

            //foreach (var item in queue)
            //{
            //    Console.WriteLine(item);
            //}

            //Queue<Action> queue = new Queue<Action>();

            //queue.Enqueue(() => { Console.WriteLine("好机会"); });
            //queue.Enqueue(() => { Console.WriteLine("我是第二个"); });
            //queue.Enqueue(() => { Console.WriteLine("他带着礼物走来了"); });

            ////queue.Dequeue();//取出移除
            ////queue.Peek();//取出不移除

            ////Console.WriteLine(queue.Peek());

            //foreach (var item in queue)
            //{
            //    ((Action)item)();
   
            //}

            //Stack
            Stack stack=new Stack(); //撤销 也有泛型

            stack.Push("欢");
            stack.Push("赢");
            stack.Push("您");

            //stack.Peek();
            //stack.Pop();//取出移除

            foreach(var item in stack)
            {
                Console.WriteLine(item);
            }

            Console.ReadKey();
        }
    }
}
